/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.spakehelpdesk.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author leehoanh
 */
@Entity
@Table(name = "News", catalog = "HelpDesk", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "News.findByType", query = "SELECT n FROM NewType nt,IN(nt.newsList) n WHERE nt.newTypeID = :newTypeID"),
    @NamedQuery(name = "News.sortByType", query = "SELECT n FROM NewType nt,IN(nt.newsList) n ORDER BY nt.newTypeID DESC"),
    @NamedQuery(name = "News.sortByDateGenerate", query = "SELECT n FROM News n ORDER BY n.dateGenerate DESC"),
    @NamedQuery(name = "News.findByDateGenerateBetween", query = "SELECT n FROM News n WHERE n.dateGenerate BETWEEN :dateGenerate1 AND :dateGenerate2"),
    @NamedQuery(name = "News.findAll", query = "SELECT n FROM News n"),
    @NamedQuery(name = "News.findByNewID", query = "SELECT n FROM News n WHERE n.newID = :newID"),
    @NamedQuery(name = "News.findByDateGenerate", query = "SELECT n FROM News n WHERE n.dateGenerate = :dateGenerate"),
    @NamedQuery(name = "News.findByRate", query = "SELECT n FROM News n WHERE n.rate > :rate")})
public class News implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    @Basic(optional = false)
    @NotNull
    @Column(name = "NewID", nullable = false)
    private Integer newID;
    @Lob
    @Size(max = 1073741823)
    @Column(name = "Title", length = 1073741823)
    private String title;
    @Lob
    @Size(max = 1073741823)
    @Column(name = "Image", length = 1073741823)
    private String image;
    @Lob
    @Size(max = 1073741823)
    @Column(name = "NewContent", length = 1073741823)
    private String newContent;
    @Column(name = "DateGenerate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateGenerate;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "Rate", precision = 15)
    private Double rate;
    @JoinColumn(name = "NewTypeID", referencedColumnName = "NewTypeID")
    @ManyToOne
    private NewType newTypeID;

    public News() {
    }

    public News(Integer newID) {
        this.newID = newID;
    }

    public Integer getNewID() {
        return newID;
    }

    public void setNewID(Integer newID) {
        this.newID = newID;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getNewContent() {
        return newContent;
    }

    public void setNewContent(String newContent) {
        this.newContent = newContent;
    }

    public Date getDateGenerate() {
        return dateGenerate;
    }

    public void setDateGenerate(Date dateGenerate) {
        this.dateGenerate = dateGenerate;
    }

    public Double getRate() {
        return rate;
    }

    public void setRate(Double rate) {
        this.rate = rate;
    }

    public NewType getNewTypeID() {
        return newTypeID;
    }

    public void setNewTypeID(NewType newTypeID) {
        this.newTypeID = newTypeID;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (newID != null ? newID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof News)) {
            return false;
        }
        News other = (News) object;
        if ((this.newID == null && other.newID != null) || (this.newID != null && !this.newID.equals(other.newID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.spakehelpdesk.entity.News[ newID=" + newID + " ]";
    }
    
}
